package com.alphasta.socketio;

import com.corundumstudio.socketio.AckRequest;
import com.corundumstudio.socketio.Configuration;
import com.corundumstudio.socketio.SocketIOClient;
import com.corundumstudio.socketio.SocketIOServer;
import com.corundumstudio.socketio.listener.DataListener;

public class SyncClientDataLauncher {

    public static void main(String[] args) throws InterruptedException {

        Configuration config = new Configuration();
        config.setHostname("");
        config.setPort(8888);

        final SocketIOServer server = new SocketIOServer(config);

        server.addEventListener("update", Object.class, new DataListener<Object>() {



            @Override
            public void onData(SocketIOClient client, Object data, AckRequest ackRequest) {

                System.out.println("服务端接收到了数据。。。" + data);
                // broadcast messages to all clients
                server.getBroadcastOperations().sendEvent("update", "我是服务器的数据哦");
            }
        });

        server.start();

        Thread.sleep(Integer.MAX_VALUE);

        server.stop();
    }
}
